Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(core): pass through paste event to pasteHandler getAttributes #4354

Merged
merged 4 commits into from
Sep 20, 2023

Conversation

bdbch
Copy link
Contributor

@bdbch bdbch commented Aug 19, 2023

Please describe your changes

This PR passes through the ClipboardEvent coming from the actual paste event down to the getAttributes function inside the pasteEvent handler for MarkPasteRule and NodePasteRules.

This allows us to do more checks on the paste without breaking out of the Tiptap priority system.

This way I also fixed an issue with the Link extension being to agressive as it was ignoring all priorities on extensions when doing the pasteHandling.

This will fix #4347 as it was the issue bringing this up to me.

How did you accomplish your changes

  • Inside the PasteHandlerPlugin I added variables to store the paste/drop events in
  • Those are passed down to the handler from where they are passed to the getAttributes function
  • After that, the paste and drop event are set back to empty events

How have you tested your changes

I tested my changes locally to see if the YouTube extension works fine again while the linking from the link extension still works on paste.

How can we verify your changes

  1. Checkout this PR
  2. Add the Link extension to the YouTube demo
  3. Try pasting a normal link (should work as usual)
  4. Try pasting a youtube video (this now should embed the video)

Remarks

  • This should be backwards compatible and non breaking as the new parameter is optional to use.

Checklist

  • The changes are not breaking the editor
  • Added tests where possible
  • Followed the guidelines
  • Fixed linting issues

Related issues

@bdbch bdbch requested a review from svenadlung as a code owner August 19, 2023 04:24
@netlify
Copy link

netlify bot commented Aug 19, 2023

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 896266d
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/64e0471da0fe2f00070e1eb4
😎 Deploy Preview https://deploy-preview-4354--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bdbch bdbch changed the base branch from develop to main August 19, 2023 04:25
@chhuang
Copy link

chhuang commented Sep 15, 2023

@bdbch any chance of getting this merged?

@bdbch bdbch merged commit 361a821 into main Sep 20, 2023
12 of 14 checks passed
BacLuc added a commit to ecamp/ecamp3 that referenced this pull request Nov 7, 2023
@nperez0111 nperez0111 deleted the bdbch/paste-rule-event-passthrough branch August 14, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug]: YouTube video pasting broken with Link extension since 2.1.0-rc.2
3 participants